<?php
namespace app\controller\open;

use app\service\AccountService;
use app\validate\VendorValidate;
use share\service\ContextService;

class UserController extends BaseOpenController{

    public function initValidate(){
        $this->validate = new VendorValidate();
    }

    public function base_action(){
        $userInfo =  ContextService::getUserInfo();
        if($userInfo){
            $res = [
                'user_id' => $userInfo['user_id'],
                'vendor' => $userInfo['vendor'],
                'location' => $userInfo['location'],
                'phone' => $userInfo['phone'],
                'phone_code' => $userInfo['phone_code'],
                'email' => $userInfo['email'],
                'picture' => $userInfo['picture'],
                'sex' => $userInfo['sex'],
                'nick_name' => $userInfo['nick_name'],
                'server_site' => $userInfo['server_site'],
            ];
            return self::ok($res);
        }
        return self::ok([]);  
    }

    public function delete_action(){
        $userInfo =  ContextService::getUserInfo();
        return self::ok(AccountService::deleteAllUserData($userInfo['user_id']));
    }
}